import java.io.*;

public class DebugLogger {
	FileOutputStream out;
	File data = new File("log.txt");
	static DataOutputStream dataOut;
	
	public DebugLogger() {
		try {
			if (data.exists()) {
				data.delete();
			}
			boolean success = data.createNewFile();
			if (success) {
				out = new FileOutputStream(data);
			} else {
				System.out.println("Could not create file");
			}
		} catch (IOException e) {
		}

		dataOut = new DataOutputStream(out);
	}
	
	public static void write(String input) {
		write(input, false);
	}
	
	public static void write(int input) {
		write(Integer.toString(input));
	}
	
	public static void write(String input, boolean print) {
		if (print) {
			System.out.println(input);
		}
		try {
			byte[] str = input.getBytes("");
			for (int pos = 0 ; pos < str.length ; pos++) {
				dataOut.writeByte(str[pos]);
			}
			dataOut.writeByte(10);
		} catch (IOException e) { System.out.println("Error writing to file!");}
	}
	
	public static void close() {
		try {
			dataOut.close();
		} catch (IOException e) {
		}
	}
}
